function getQueryString(name) {
  var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  var r = window.location.search.substr(1).match(reg);
  if (r != null) {
      return unescape(r[2]);
  }
  return null;
}

//每日签到效果
(function(){
    var flag = true;
    $(".personalMsg .contentSign").click(function(){
        if(flag){
            $(this).css({"background":"#ccc"}).find("span").html("已&nbsp;&nbsp;&nbsp;签");
        }
        flag = false;

    });

})();
var isShowPatientList = getQueryString("record");
if(isShowPatientList){
  $(".record").css({"transform":"translateX(0)"});
}
(function(){
    $(".toRecord").click(function(){
        $(".record").css({"transform":"translateX(0)"});
    });
    $(".record .header").click(function(){
        $(".record").css({"transform":"translateX(100%)"});
    });
}());

//性别
var data1 = [ {
    text:'男', 
    value:1
  },  {
    text:'女', 
    value:0
  }
]; 
var  picker1El = document.getElementById("gender"); 
var picker1 = new Picker( {
  data:[data1]
}); 

picker1.on('picker.select', function (selectedVal, selectedIndex) {
  picker1El.value = data1[selectedIndex[0]].text; 
}); 
picker1El.addEventListener('click', function () {
  picker1.show(); 
}); 

// 与患者关系
var data2 = [ {
  text:'其他', 
  value:0
},  {
  text:'父子', 
  value:1
},  {
  text:'母子', 
  value:1
},  {
  text:'本人', 
  value:1
},  {
  text:'父女', 
  value:1
},  {
  text:'母女', 
  value:1
},  {
  text:'夫妻', 
  value:1
}
]; 
var  picker2El = document.getElementById("relation"); 
var picker2 = new Picker( {
  data:[data2]
}); 

picker2.on('picker.select', function (selectedVal, selectedIndex) {
  picker2El.value = data2[selectedIndex[0]].text; 
}); 
picker2El.addEventListener('click', function () {
  picker2.show(); 
}); 

// 选择日期
$(function () {
  var currYear = (new Date()).getFullYear();	
  var opt={};
  opt.date = {preset : 'date'};
  opt.datetime = {preset : 'datetime'};
  opt.time = {preset : 'time'};
  opt.default = {
      theme: 'android-ics light', //皮肤样式
      display: 'modal', //显示方式 
      mode: 'scroller', //日期选择模式
      dateFormat: 'yyyy-mm-dd',
      lang: 'zh',
      showNow: true,
      nowText: "今天",
      startYear: currYear - 100, //开始年份
      endYear: currYear  //结束年份
  };

  $("#USER_AGE").mobiscroll($.extend(opt['date'], opt['default']));

});

$(".toCreateUser").click(function(){
    $(".createUser").css({"transform":"translateX(0)"});
});
$(".createUser .cancel").click(function(){
    $(".createUser").css({"transform":"translateX(100%)"});
});
$(".createUser .save").click(function(){
    var params= {
        patient: $("#patient").val(),
        gender: $("#gender").val(),
        USER_AGE: $("#USER_AGE").val(),
        relation: $("#relation").val(),
        picker5: $("#picker5").val(),
        tel: $("#tel").val(),
        ID: $("#ID").val(),
        cardNum: $("#cardNum").val(),
    };
    $.ajax({
        url:'',
        method:"post",
        data:params,
        dataType:'json',
        success:function(){
            $(".createUser").css({"transform":"translateX(100%)"});
        }
    });
});
$(".info input").click(function(){
  $(".createUserWrap").css({"paddingBottom":"4rem"});
});






